/*
 *         Copyright (c) KUBOTA Corporation and HUDSON SOFT,
 *                  1994, 1995 All Rights Reserved
 *
 *  This software comprises unpublished confidential information of
 *  KUBOTA Corp. and HUDSON SOFT. It may not be used, copied or made 
 *  available to anyone, except in accordance with the license under
 *  which it is furnished.
 */
static char SccsId[] = "@(#)cube27.c	1.8	9/19/95";
#include <farl.h>
#include <agl.h>
#define OBJNum		27

unsigned int cube[] = {
#include "cubestp.h"
};

Material	mt1[1] = {{0x1000, 0x3fff, 0x3fff,}};
object	o[OBJNum] = {0,};

void
main()
{
     register int		i, j;
     fix187	otrans[OBJNum][3] = {
	  0x40,   0x40,   0x40,	/* ( 1, 1, 1) */
	  0x0,    0x40,   0x40,	/* ( 0, 1, 1) */
	  0xffc0, 0x40,   0x40,	/* (-1, 1, 1) */
	  0xffc0, 0x0,    0x40,	/* (-1, 0, 1) */
	  0xffc0, 0xffc0, 0x40,	/* (-1,-1, 1) */
	  0x0,    0xffc0, 0x40,	/* ( 0,-1, 1) */
	  0x40,   0xffc0, 0x40,	/* ( 1,-1, 1) */
	  0x40,   0x0,    0x40,	/* ( 1, 0, 1) */
	  0x0,    0x0,    0x40,	/* ( 0, 0, 1) */

	  0x40,   0x40,   0x0,	/* ( 1, 1, 0) */
	  0x0,    0x40,   0x0,	/* ( 0, 1, 0) */
	  0xffc0, 0x40,   0x0,	/* (-1, 1, 0) */
	  0xffc0, 0x0,    0x0,	/* (-1, 0, 0) */
	  0xffc0, 0xffc0, 0x0,	/* (-1,-1, 0) */
	  0x0,    0xffc0, 0x0,	/* ( 0,-1, 0) */
	  0x40,   0xffc0, 0x0,	/* ( 1,-1, 0) */
	  0x40,   0x0,    0x0,	/* ( 1, 0, 0) */
	  0x0,    0x0,    0x0,	/* ( 0, 0, 0) */

	  0x40,   0x40,   0xffc0, /* ( 1, 1,-1) */
	  0x0,    0x40,   0xffc0, /* ( 0, 1,-1) */
	  0xffc0, 0x40,   0xffc0, /* (-1, 1,-1) */
	  0xffc0, 0x0,    0xffc0, /* (-1, 0,-1) */
	  0xffc0, 0xffc0, 0xffc0, /* (-1,-1,-1) */
	  0x0,    0xffc0, 0xffc0, /* ( 0,-1,-1) */
	  0x40,   0xffc0, 0xffc0, /* ( 1,-1,-1) */
	  0x40,   0x0,    0xffc0, /* ( 1, 0,-1) */
	  0x0,    0x0,    0xffc0, /* ( 0, 0,-1) */
     };

     FX73init();
     FX73_cmap_i6c3();
     AGLInit();

     FarlSetPEICMaskReg(FARL_ICMASK_I6C3);
     FarlSetTEControlReg(  FARL_TE_LTEN | FARL_TE_ICM
			 | FARL_TE_SPEN | FARL_TE_BCE);

     for (i = 0; i < OBJNum; i++) {
	  o[i].geometryTop    = cube;
	  o[i].geometryLength = sizeof(cube)/sizeof(int);
	  o[i].material = NULL;
     }
     o[0].material = &(mt1[0]);

     AGLSetMaterial(mt1, 1);

     AGLResetCamera();
     AGLTranslateCamera(0x0, 0x0, 0x95);
     AGLPerspectiveCamera(0xff9a);
     for ( i = 0 ; ; i += 10 ) {
	  for ( j = 0 ; j < OBJNum ; j++ ) {
	       AGLResetObj(&(o[j]));
	       AGLScaleObj(&(o[j]), 0x60, 0x60, 0x60);
	       AGLTranslateObj(&(o[j]), otrans[j][0], otrans[j][1], otrans[j][2]);
	       AGLRotateObjY(&(o[j]), i%3600);
	       AGLRotateObjX(&(o[j]), i%3600);
	       AGLRotateObjZ(&(o[j]), i%3600);
	  }

	  for (j = 0; j < OBJNum; j++) AGLFixPutObj(&(o[j]));
	  AGLShot();
     }
     return;
}
